#ifndef WINDOW_H
#define WINDOW_H

#include <QMainWindow>
#include <QtGui>

#include "glwidget.h"
#include "defines/global.h"

class Window : public QMainWindow{
    Q_OBJECT

    public:
        Window();
        ~Window();

    private slots:
        void openCAFile();
        void importOBJFile();
        void playbackSimulation();
        void changeToForwardEulerMethod(bool);
        void changeToMidpointMethod(bool);
        void changeToRungeKuttaMethod(bool);
        void changeToAdaptiveRungeKuttaMethod(bool);
        void changeToImprovedVerlet(bool);
        void changeToAproximatedImplicit(bool);
        void changeToImplicitSOR(bool);
        void changeToHybridIntegration(bool);
        void changeToImplicitJacobi(bool);
        void changeToAproximatedJacobi(bool);
        void restartMode();
        void changeMode(int);
        void startPauseSimulation(bool);
        void stopSimulation();
        void recordSimulation(bool);

        void updateAdjacency();
        void updateGravity();
        void updateDeltaT();

        void updateActiveCollision();
        void updateDistanceError();
        void updateDampingFactor();

        void updateActiveAir();
        void updateAirType();
        void updateAirDirection();
        void updateAirViscosity();

        void updateImplicitJacobiThreshold();
        void updateImplicitJacobiMaxIteration();
        void updateImplicitSORThreshold();
        void updateImplicitSORRelaxation();
        void updateImplicitSORMaxIteration();
        void updateImprovedVerletEta();

        void addObject(Object *);
        void deleteObject();
        void deleteFabric();
        void addSphere();
        void editObjectDialog(QTreeWidgetItem *, int);
        void editFabricDialog(QTreeWidgetItem *, int);

        void changeObjectsSelection();
        void changeFabricsSelection();

    private:
        int mode; //0 - edição; 1 - simulação; 2 - reprodução
        unsigned int objectId;
        unsigned int method;
        bool fabricInOperation;
        bool objectInOperation;

        QString fileName;
        QString playbackFileName;
        GLWidget *glWidget;
        QTreeWidget *fabricTree;
        QTreeWidget *objectTree;
        GlobalOptionsPanel *globalOptionsPanel;
        CollisionOptionsPanel *collisionOptionsPanel;
        AirOptionsPanel *airOptionsPanel;
        MethodsOptionsPanel *methodsOptionsPanel;
        QComboBox *modeComboBox;

        QAction *forwardEulerMethodAct;
        QAction *midpointMethodAct;
        QAction *rungeKuttaMethodAct;
        QAction *adaptiveRungeKuttaMethodAct;
        QAction *improvedVerletAct;
        QAction *aproximatedImplicitAct;
        QAction *implicitSORAct;
        QAction *hybridIntegrationAct;
        QAction *implicitJacobiAct;
        QAction *aproximatedJacobiAct;
//              QWidget *playWidget;
        QAction *startPauseAct;
        QAction *stopAct;
        QAction *restartAct;
        QAction *recordAct;

        QAction *deleteObjectAct;
        QAction *deleteFabricAct;

        QDockWidget *methodsOptionsPanelDock;

        QList<QTreeWidgetItem *> previousSelectedObjects;
        QList<QTreeWidgetItem *> previousSelectedFabrics;

        void createActionsMenusToolbar();
        void openFile();
        void openPlaybackFile();
        void updateActions();
        void changeSolver();
};

#endif
